﻿#include "ComManageWidget.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#pragma execution_character_set("utf-8")

ComManageWidget::ComManageWidget(QWidget *parent)
    : QWidget{parent}
{
    initComManage();
    setupUI();
}

void ComManageWidget::setupUI()
{
    QHBoxLayout* hLayout = new QHBoxLayout();
    this->setLayout(hLayout);
    QTabWidget* tab = new QTabWidget();
    hLayout->addWidget(tab);
    tab->addTab(mPLCClientManage->getPLCClientManageWidget(), "PLCClient");
    tab->addTab(mPLCServerManage->getPLCServerManageWidget(), "PLCServer");
    tab->addTab(mComClientManage->getComClientManageWidget(), "ComClient");
    tab->addTab(mComServerManage->getComServerManageWidget(), "ComServer");
}

void ComManageWidget::initComManage()
{
    mPLCServerManage = new PLCServerManage(this);
    mPLCServerManage->initWgtPLCServerStatus();
    mPLCServerManage->initPLCServerManageWidget();
    mPLCServerManage->initPLCServerAll();
    mPLCServerManage->startWorker();

    mPLCClientManage = new PLCClientManage(this);
    mPLCClientManage->initWgtPLCClientStatus();
    mPLCClientManage->initPLCClientManageWidget();
    mPLCClientManage->initPLCClientAll();
    mPLCClientManage->startWorker();

    mComClientManage = new ComClientManage(this);
    mComClientManage->initWgtComClientStatus();
    mComClientManage->initComClientManageWidget();
    mComClientManage->initComClientAll();
    mComClientManage->startWorker();

    mComServerManage = new ComServerManage(this);
    mComServerManage->initWgtComServerStatus();
    mComServerManage->initComServerManageWidget();
    mComServerManage->initComServerAll();
    mComServerManage->startWorker();

}
